package com.ft.turorial.spring.boot.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ft.turorial.spring.boot.domain.User;
import com.ft.turorial.spring.boot.mapper.UserRunAsMapper;

@Service
public class UserRunAsServiceImpl implements UserRunAsService {
    @Resource
    private UserRunAsMapper userRunAsMapper;

    @Override
    public void grantRunAs(Integer fromUserId, Integer toUserId) {
    	userRunAsMapper.grantRunAs(fromUserId, toUserId);
    }

    @Override
    public void revokeRunAs(Integer fromUserId, Integer toUserId) {
    	userRunAsMapper.revokeRunAs(fromUserId, toUserId);
    }

    @Override
    public boolean exists(Integer fromUserId, Integer toUserId) {
    	Long result = userRunAsMapper.exists(fromUserId, toUserId);
        return result==1L;
    }

    @Override
    public List<User> findByFromUserIds(Integer toUserId) {
        return userRunAsMapper.findByFromUserIds(toUserId);
    }

    @Override
    public List<User> findByToUserIds(Integer fromUserId) {
        return userRunAsMapper.findByToUserIds(fromUserId);
    }
}
